import request from "@/utils/request";
//查询全部部门数据
//export：将数据抛出（谁调用就抛出给谁）

//新增
export const addApi = (user) => request.post('/user/addUser', user);

//查询
export const queryApi = (name, gender, begin, end, page, pageSize) => {
  // 构建查询参数对象
  const params = {
    name: name || undefined,
    gender: gender || undefined,
    begin: begin || undefined,
    end: end || undefined,
    page: page,
    pageSize: pageSize
  };
  
  // 使用axios的params参数，让axios自动处理参数构建和编码
  return request.get('/user/page', { params });
}

//根据id用户信息
export const queryInfoApi = (id) => request.get(`/user/${id}`)

//修改用户信息
export const updataApi = (user) => request.put('/user/updataUser',user)

//删除单个用户数据
export const deleteApi = (id) => request.delete(`/user/deleteUser/${id}`)




